import matplotlib
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np

matplotlib.use("Agg")


class Dummy:
    def __init__(self, fname):
        self.fname = fname
        self.video = []
        self.fig, self.ax = plt.subplots()  # Create new figure here

    def addFrame(self):
        # Frame = np.random.rand(10, 10)
        # print(Frame)
        Frame = np.zeros((10, 10))
        self.video.append((self.ax.pcolormesh(Frame),))

    def saveVideo(self):
        Writer = animation.writers['ffmpeg']
        writer = Writer(fps=30, metadata=dict(artist='XY'), bitrate=3600)
        im_ani = animation.ArtistAnimation(self.fig, self.video, interval=500,
                                           repeat_delay=3000, blit=True)
        im_ani.save(self.fname, writer=writer)


foo1 = Dummy('foo1.mp4')
for i in range(23550):
    foo1.addFrame()
foo1.saveVideo()
